<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Change Parent Component message</title>
</head>
<body>
<div id="app">
  <com-a :parent-msg="msg" @child-event="parentFn"></com-a>
</div>

<script src="../vue.global.js"></script>
<script>
  const ComA = {
    data(){
      return{
        msg: 'children component'
      }
    },
    props: ['parentMsg'],
    emits: ['child-event'],
    template: `
    <h1>{{parentMsg}}</h1>
    <h1>{{msg}}</h1>
    <h3><button @click="childClick(msg)">{{msg}}</button></h3>
    `,
    methods: {
      childClick(value){
        this.$emit('child-event', value)
      }
    },
  }
  const ComB = {}
  const app = Vue.createApp({
    data(){
      return{
        msg: "parent component"
      }
    },
    components: {
      'com-a': ComA,
      'com-b': ComB,
    },
    methods: {
      parentFn(value){
        this.msg = value
      }
    }
  })
  const vm = app.mount('#app')
  console.log(vm.msg)
</script>
</body>
</html>
